Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete: Implement context filter #3897

Merged
merged 4 commits into from
Apr 22, 2024

Conversation

philipp-spiess
Copy link
Contributor

@philipp-spiess philipp-spiess commented Apr 22, 2024

Part of #3642
Part of #3604

This PR implements context filter honoring for Autocomplete. There are two types of sources we filter:

  • The current file context (appended as prefix/suffix) to the prompt: In files that are ignored, autocomplete will now no-op. Question: should this print a log somewhere that a user can see it so it's clear why Autocomplete does not work? I am worried that anything we add might be annoying, though.
  • Retrieved file context: we now filter all retrieved context before ranking. We can move some of the checks closer into the retrievers but since all of the retrievers are local and fast, this is not a high prioroity

Test plan

  • Added tests

@philipp-spiess philipp-spiess changed the title Autocomplete: Implement context filter" Autocomplete: Implement context filter Apr 22, 2024
@@ -55,6 +58,10 @@ const defaultOptions = {
}

describe('ContextMixer', () => {
beforeEach(() => {
vi.spyOn(contextFiltersProvider, 'isUriAllowed').mockImplementation(() => Promise.resolve(true))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valerybugakov Do you think it reasonable to manually mock this method for all tests or should we try to mock it automatically for all tests? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean for all tests in the codebase? In some cases, we mock the underlying logic only (e.g., isRepoNameIgnored or fetchContextFilters), so un-mocking the isUriAllowed function would be necessary, which is not ideal. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valerybugakov Oh no I didn't mean we should add this mock automatically but rather just make you aware that with the current config, we will have to update all tests that call into the context filters to add this line on top. Seems reasonable I guess?

Base automatically changed from ps/call-filter-before-sending-upstream to main April 22, 2024 13:03
@dominiccooney
Copy link
Contributor

@philipp-spiess

Question: should this print a log somewhere that a user can see it so it's clear why Autocomplete does not work? I am worried that anything we add might be annoying, though.

We're going to have UX treatment for ignored files (for example, banner in JetBrains) which explain what is going on. A log at the verbose log level would be good.

Copy link
Contributor

@dominiccooney dominiccooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philipp-spiess
Copy link
Contributor Author

We're going to have UX treatment for ignored files (for example, banner in JetBrains) which explain what is going on

Ah awesome, I also saw this as a P1 here now: #3604. If that's planned, I'll not be closing this one.

Verbose log for autocomplete is a bit annoying (since it will fire on every keystroke). I'll add a simple guard so that repeated calls for the same URI don't log something, this should be good enough for now and only requires us to keep a string value stored and compared against.

@philipp-spiess philipp-spiess merged commit 77da391 into main Apr 22, 2024
20 checks passed
@philipp-spiess philipp-spiess deleted the ps/call-filter-autocomplete branch April 22, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants